-
Notifications
You must be signed in to change notification settings - Fork 135
fix(gas): fix batch listen, fix history for graceful signal send in workflows #3479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 11-17-feat_gas_add_batch_listen
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
3 Skipped Deployments
|
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
How to use the Graphite Merge QueueAdd the label merge-queue to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
PR Review: Fix batch listen, fix history for graceful signal send in workflowsSummaryThis PR introduces two main improvements to the gasoline workflow engine:
Code Quality & Best PracticesStrengths:
Suggestions:
Potential Bugs & IssuesCritical:
Minor:
Performance ConsiderationsImprovements:
Concerns:
Security ConcernsNo security issues identified. The changes:
Test CoverageMissing test scenarios:
Recommended test additions: // Test graceful signal send with replay
#[test]
async fn test_graceful_signal_not_found_replay() {
// First run: target doesn't exist, should create removed event
// Second run: should replay removed event correctly
}
// Test batch signal ordering
#[test]
async fn test_batch_signal_timestamp_ordering() {
// Create signals with out-of-order timestamps
// Verify they're received in timestamp order
}Additional Notes
VerdictLGTM with minor suggestions This is a solid improvement to the workflow engine. The graceful signal sending feature is well-implemented with proper history tracking for replay consistency. The batch listen fixes address real bugs in signal ordering and indexed chunk handling. The loop optimization should provide measurable performance improvements. The code follows project conventions, has good documentation, and maintains backward compatibility. Recommended to merge after addressing the test coverage gaps. Recommendation: Approve with suggestion to add tests before merge. |
More templates
@rivetkit/cloudflare-workers
@rivetkit/db
@rivetkit/framework-base
@rivetkit/next-js
@rivetkit/react
rivetkit
@rivetkit/sql-loader
@rivetkit/engine-runner
@rivetkit/engine-runner-protocol
commit: |
25ece3d to
6ff29f6
Compare
0ca2fa2 to
321b2c3
Compare
|
Critical Issues - Must Fix Before Merge
Affected locations:
Example of what needs fixing - change from this pattern: To this pattern:
Positive Changes:
Recommendations:
The core concept is solid - adding graceful degradation for missing signal targets is the right approach. However, compilation errors need fixing before merge. |
Code Review: Batch Listen & Graceful Signal SendThis PR introduces important improvements to the workflow signal system, but there are several critical issues that need to be addressed before merging. Critical Issue: Missing runner2 ModuleSeverity: Critical - Breaks Compilation Multiple files reference workflows::runner2 but the module does not exist:
However, engine/packages/pegboard/src/workflows/mod.rs only declares pub mod actor and pub mod runner. Fix Required: Either add pub mod runner2 and create the module file, OR revert all references back to runner if runner2 was intended for a different PR. |
Code Quality Issues1. Potential Logic Issue in Batch Listen Sort/LimitSeverity: Medium In engine/packages/gasoline/src/db/kv/mod.rs:1945-2067, the limit is applied twice:
If there are multiple signal types in the filter, this could fetch more signals than needed. For example, with 3 signal types and limit=10, you might fetch up to 30 signals, then sort and take 10. Recommendation: Consider using limit: None in the initial fetch, or adjust the per-type limit to account for multiple signal types. 2. Inconsistent Event Type NamingSeverity: Low The signal batch receive event is called different things across the codebase:
Consider standardizing terminology. |
Good Practices Observed1. Excellent Error Handling PatternThe graceful_not_found() API is well-designed and much cleaner than the previous pattern of checking for specific error types. This is a clean builder API that improves code readability significantly! 2. Proper History Tracking for Graceful Not FoundThe implementation correctly handles replay scenarios by:
This maintains workflow determinism properly. 3. Loop Optimization ParallelizationThe loop optimization in engine/packages/gasoline/src/ctx/workflow.rs:866-979 is well-documented with detailed comments explaining the parallelization strategy, which is excellent for maintainability. |
Test CoverageMissing Tests for New FeaturesSeverity: Medium The PR adds significant new functionality but I do not see corresponding tests:
Recommendation: Add integration tests in engine/packages/gasoline/tests/workflows/ following the pattern of signal_test.rs. |
SummaryMust Fix Before Merge:
Should Fix: Nice to Have: Overall, this is a solid improvement to the signal system with good attention to replay consistency and error handling. The main blocker is the runner2 compilation issue. Once that is resolved and tests are added, this should be ready to merge. Great work on the graceful error handling pattern! |
6ff29f6 to
dba469c
Compare
321b2c3 to
aa9ef2a
Compare
Pull Request ReviewThis PR introduces important fixes for batch signal listening and adds graceful handling for signal sends when the target workflow doesn't exist. Here's my analysis: ✅ Strengths
🔍 Issues & ConcernsCritical: Index Bug in Batch ListenAt let packed_key = self.subspace.pack(&key);In the main code path, you pack with .into_iter().take(limit).enumerate()This Issue: You fetch up to Minor: Duplicate Index Insertion LogicThe code at if let Some(input_chunks) = current_event.indexed_input_chunks.get_mut(key.index) {
input_chunks.push(entry);
} else {
current_event.indexed_input_chunks.insert(key.index, vec\![entry]);
}This is correct but could be simplified to Minor: EventType ConsistencyAt 🎯 Suggestions
📋 Nitpicks
Overall AssessmentThis is a solid PR that addresses real issues in signal handling and workflow loop performance. The graceful error handling pattern is a valuable addition to the API. The batch listen fix is important for correctness. Recommendation: ✅ Approve with minor suggestions The critical concern about batch listen limit handling should be verified/documented, but the code appears functionally correct. Consider adding tests for the new graceful handling behavior before merging. |
Pull Request ReviewThanks for this PR @MasterPtato! I've reviewed the changes for fixing batch listen and history for graceful signal sending in workflows. Overall, the implementation looks solid with good attention to detail. Here are my findings: 🎯 Strengths1. Graceful Signal Handling ✅
2. Batch Listen Fix ✅
3. Loop Event Optimization ✅
4. Error Handling Cleanup ✅
🔍 Issues & Concerns1. Index Handling in Debug Code if let Some(input_chunks) = current_event.indexed_input_chunks.get_mut(key.index) {
input_chunks.push(entry);
} else {
current_event.indexed_input_chunks.insert(key.index, vec![entry]);
}Issue: The
Recommendation: Either remove the defensive 2. Missing Test Coverage
Recommendation: Add test coverage for these critical scenarios, especially: // Test that batch listen returns signals in timestamp order
// Test that graceful_not_found returns None without error
// Test that replaying a gracefully failed signal works correctly3. History Event Type Inconsistency ℹ️ 4. Potential Race Condition
Question: Should the limit be applied per-stream or globally? Current implementation applies it globally after merging, which seems correct but could result in fetching more than 🎨 Code QualityPositive:
Minor:
🔒 SecurityNo security concerns identified. The changes don't introduce:
⚡ PerformancePositive:
Note: The sorting of signals (line 1980) could be expensive with many signals, but this is necessary for correctness. Consider adding metrics to monitor the number of signals being sorted. 📊 Summary
✅ Recommendations
🚀 ApprovalDespite the missing test coverage, the core implementation is sound and the changes are necessary fixes. I recommend:
Great work on the complex async optimizations! The deferred loop upsertion is particularly clever. |
aa9ef2a to
dfd167c
Compare
dba469c to
2a53bcf
Compare
Pull Request ReviewSummaryThis PR introduces two significant improvements to the Gasoline workflow engine:
Code Quality & Best Practices✅ Strengths
|
Code ReviewSummaryThis PR fixes two important issues in the Gasoline workflow engine:
Positive ObservationsStrong Design Decisions
Good Code Quality
Issues & Concerns1. Critical: Potential Race Condition in Batch ListenLocation: The batch listen implementation sorts signals AFTER fetching them from multiple streams. Each individual stream fetch has Recommendation: Remove the per-stream limit and only apply limit after sorting, OR fetch more than needed from each stream. 2. Bug: Missing Removal Event in Common Signal BuilderLocation: The common (non-workflow) signal builder returns Impact: If this code path is used in any replay scenarios, the replay will fail due to missing history events. Recommendation: Add the removed event commit in the common builder as well, or document why it's not needed. 3. Inconsistency: Signal ID GenerationLocation: In the common builder, Recommendation: Move ID generation to after the workflow lookup check. 4. Test Coverage ConcernNo new tests were added for the Recommendation: Add tests covering graceful signal send to non-existent workflow, replay of gracefully not found signal, and graceful signal in loops. 5. Minor: Duplicate Code in Batch ListenLocation: The same logic for handling indexed_input_chunks appears twice, suggesting the initialization might be missing elsewhere. Performance ConsiderationsPositive
Concerns
Security ReviewNo security issues identified. The changes don't introduce SQL injection risks, authentication/authorization bypass, data leakage, or command injection. Documentation
Recommendations SummaryMust Fix:
Should Fix: Nice to Have: VerdictThis PR makes important improvements to reliability (graceful signal handling) and correctness (batch listen ordering). However, the batch listen race condition is critical and should be addressed before merging. The missing test coverage is also concerning for such a significant behavior change. Recommendation: Request changes to fix the batch listen limit issue and add test coverage. |
dfd167c to
bcf4d5d
Compare
2a53bcf to
633c857
Compare
PR Review: fix(gas): fix batch listen, fix history for graceful signal send in workflowsSummaryThis PR introduces several fixes to the gasoline workflow engine:
Code Quality ✅Good patterns observed:
Suggestions:
Potential Bugs / Issues
|
PR Review: fix(gas): fix batch listen, fix history for graceful signal send in workflowsSummaryThis PR introduces several improvements to the gasoline workflow engine:
✅ Positive Changes1. Clean API Design 2. Proper History Tracking 3. Improved Code Readability if let Some(WorkflowError::WorkflowNotFound) = res
.as_ref()
.err()
.and_then(|x| x.chain().find_map(|x| x.downcast_ref::<WorkflowError>()))
{ ... }to: if res.is_none() { ... }is much cleaner and easier to understand. 4. Bug Fix: Batch Listen Signal Ordering 5. Bug Fix: Event Type Correction 6. Performance: Deferred Loop Upsertion
|

No description provided.